﻿function InitializeMap(centerLat, centerLon, minZoomLevel, zoomLevel) {
    var origin = [-180, 90];//图层起点坐标，经度偏移，维度偏移
    var resolutions = [
        1.40625000000024,// Level 0
        0.703125000000119,// Level 1
        0.351562500000059,// Level 2
        0.17578125000003,// Level 3
        0.0878906250000148,// Level 4
        0.0439453125000074,// Level 5
        0.0219726562500037,// Level 6
        0.0109863281250019,// Level 7
        0.00549316406250093,// Level 8
        0.00274658203125046,// Level 9
        0.00137329101562523,// Level 10
        0.000686645507812616,// Level 11
        0.000343322753906308,// Level 12
        0.000171661376953154,// Level 13
        8.5830688476577E-05,// Level 14
        4.29153442382885E-05,// Level 15
        2.14576721191443E-05,// Level 16
        1.07288360595721E-05,// Level 17
        5.36441802978606E-06 // Level 18
        //2.68220901489303E-06,// Level 19
        //1.34110450744652E-06// Level 20
    ];
    var crs = new L.Proj.CRS(
        'EPSG:4326',
        '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs',
        {
            origin: origin,
            resolutions: resolutions
        }
    );

    var centerPoint = new L.LatLng(centerLat, centerLon);

    map = L.map('map', {
        center: centerPoint,
        crs: crs,
        maxZoom: resolutions.length - 1,
        minZoom: minZoomLevel,
        zoom: zoomLevel,
        continuousWorld: true,
        attributionControl: true,
        worldCopyJump: false,
        pin: true,
        pinCircle: true,
        pinControl: true,
        guideLayers: []
    });

    map.zoomControl.setPosition('bottomright');

    map.addControl(L.control.basemaps({
        position: 'topright'
    }));
    L.control.scale().addTo(map);
}